package com.lyshop.jinding.view;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.lyshop.jinding.R;
import com.lyshop.jinding.utils.GoodsUtils;
import com.zc.mychart.model.GoodsAllBean;
import com.zc.mychart.model.GoodsItemBean;


public class GoodCostDialog extends MyDialog implements View.OnClickListener {

    private View rootView;
    private TextView tv_goods_money;
    private TextView tv_confirm;

    private MoneyTextView mtv_material_support;
    private MoneyTextView mtv_premium;
    private MoneyTextView mtv_loss;
    private MoneyTextView mtv_technology;
    private MoneyTextView mtv_taxes;
    private MoneyTextView mtv_total_money;

    private DialogListener mListener;

    public GoodCostDialog(Context context) {
        this(context, true, Gravity.CENTER);
    }

    public GoodCostDialog(Context context, boolean isCancelAble, int gravity) {
        super(context, isCancelAble, gravity);
        rootView = LayoutInflater.from(context).inflate(R.layout.dialog_goods_cost, null);
        setContentView(rootView);

//        tv_goods_money = rootView.findViewById(R.id.tv_goods_money);
        tv_confirm = rootView.findViewById(R.id.tv_confirm);

        mtv_material_support = findViewById(R.id.mtv_material_support);
        mtv_premium = findViewById(R.id.mtv_premium);
        mtv_loss = findViewById(R.id.mtv_loss);
        mtv_technology = findViewById(R.id.mtv_technology);
        mtv_taxes = findViewById(R.id.mtv_taxes);

        tv_confirm.setOnClickListener(this);

    }

    public void setGoodsMoney(GoodsAllBean mGroupBean, GoodsItemBean mProInfoItemBean) {
        double mTotalMoney = GoodsUtils.setGoodsMoneyCalculate(mGroupBean.latest_price, 1, mProInfoItemBean,
                null, mtv_material_support, mtv_premium, mtv_loss, mtv_technology, mtv_taxes);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_confirm:
                if (isCancelAble) {
                    dismiss();
                }
                break;
        }
    }


    public interface DialogListener {
        void onConfirm();

        void onCancel();
    }

}

